package cn.com.yang.task;

import java.time.LocalDateTime;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 开启定时任务
 * TODO
 * @author yangyijin
 * @since 2023年10月31日-上午9:28:47
 */
@Component
@Async
public class TestAsyncTask {
	
	@Scheduled(cron="0/5 * * * * ?")
	@Async
	public void task1() throws InterruptedException {
		System.out.println("执行定时任务1 "+LocalDateTime.now());
		Thread.sleep(10*1000);
	}
	@Scheduled(cron="0/5 * * * * ?")
	@Async
	public void task2() {
		System.out.println("执行定时任务2 "+LocalDateTime.now());
	}
}
